//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.yang.newcustomcuilian.commander;

import com.yang.newcustomcuilian.NewCustomCuiLian;
import com.yang.newcustomcuilian.language.Language;
import com.yang.newcustomcuilian.level.Level;
import com.yang.newcustomcuilian.loader.Loader;
import com.yang.newcustomcuilian.movelevel.MoveLevelInventory;
import com.yang.newcustomcuilian.newapi.NewAPI;
import com.yang.newcustomcuilian.stone.Stone;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class Commander implements CommandExecutor {
    public Commander() {
    }

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!sender.isOp()) {
            sender.sendMessage("[" + NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getName() + "]不是OP");
        } else if (args.length == 1 && args[0].equals("openMoveLevelInv")) {
            MoveLevelInventory.open((Player)sender);
        } else if (!sender.isOp()) {
            sender.sendMessage("[" + NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getName() + "]不是OP");
        } else {
            Player pp;
            if (args.length == 2 && args[0].equals("set")) {
                pp = (Player)sender;
                NewAPI.setItemInHand(pp, NewAPI.setItemCuiLian(NewAPI.getItemInHand(pp), NewAPI.getLevelByInteger(Integer.parseInt(args[1]) - 1), pp));
            } else if (args.length == 0) {
                sender.sendMessage("§c§m§l  §6§m§l  §e§m§l  §a§m§l  §b§m§l  §e§l淬炼§b§m§l  §a§m§l  §e§m§l  §6§m§l  §c§m§l  ");
                sender.sendMessage("§c§l▏   §c/cuilian cuilianshi(淬炼石) id 数量 玩家");
                sender.sendMessage("§c§l▏   §c/cuilian baohufu(保护符) 对应的等级 数量 玩家");
                sender.sendMessage("§c§l▏   §c/cuilian openMoveLevelInv 打开移星面板");
                sender.sendMessage("§c§l▏   §c/cuilian set 等级");
                sender.sendMessage("§c§l▏   §c/cuilian reload 重载插件");
                sender.sendMessage("§c§l▏   §c/cuilian getType 获取物品类型");
                sender.sendMessage("§c§l▏   §c/cuilian addToItem arms|helmet|chestplate|leggings|boots 把手持物品加入可淬炼列表");
                sender.sendMessage("§c§m§l  §6§m§l  §e§m§l  §a§m§l  §b§m§l  §e§l淬炼§b§m§l  §a§m§l  §e§m§l  §6§m§l  §c§m§l  ");
            } else if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
                Loader.readVariables(NewCustomCuiLian.getPlugin(NewCustomCuiLian.class));
                Loader.readCuiLianItem(NewCustomCuiLian.getPlugin(NewCustomCuiLian.class));
                Loader.readItem(NewCustomCuiLian.getPlugin(NewCustomCuiLian.class));
                Loader.readYml(NewCustomCuiLian.getPlugin(NewCustomCuiLian.class));
                Language.loadLanguage(NewCustomCuiLian.getPlugin(NewCustomCuiLian.class));
                NewCustomCuiLian.reloadRecipe();
                sender.sendMessage("[" + NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getName() + "]插件重载完毕");
            } else if (args.length == 1 && args[0].equalsIgnoreCase("getType")) {
                pp = (Player)sender;
                pp.sendMessage(NewAPI.getItemInHand(pp).getType().name());
            } else if (args.length == 2 && args[0].equalsIgnoreCase("addToItem")) {
                pp = (Player)sender;
                Loader.addTypeToItem(NewAPI.getItemInHand(pp).getType(), args[1], NewCustomCuiLian.getPlugin(NewCustomCuiLian.class));
                sender.sendMessage("[" + NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getName() + "]成功将手持物品:" + NewAPI.getItemInHand(pp).getType() + "加入Item.yml." + args[1]);
            } else if (args.length == 4) {
                pp = NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getServer().getPlayer(args[3]);
                if (pp == null) {
                    sender.sendMessage("[" + NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getName() + "]§c玩家不在线");
                }

                int sl2;
                ItemStack item2;
                if (args[0].equalsIgnoreCase("cuilianshi")) {
                    sl2 = Integer.parseInt(args[2]);
                    if ((NewCustomCuiLian.customCuilianManager.customCuilianStoneList.size() - 1 < Integer.parseInt(args[1]) - 1 || Integer.parseInt(args[1]) - 1 < 0) && pp != null) {
                        pp.sendMessage("[" + NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getName() + "]不存在的淬炼石");
                    }

                    item2 = ((Stone)NewCustomCuiLian.customCuilianManager.customCuilianStoneList.get(Integer.parseInt(args[1]) - 1)).cuiLianStone;
                    item2.setAmount(sl2);
                    if (pp != null) {
                        pp.getInventory().addItem(new ItemStack[]{item2});
                    }
                } else if (args[0].equalsIgnoreCase("baohufu")) {
                    sl2 = Integer.parseInt(args[2]);
                    if (((Level)NewCustomCuiLian.customCuilianManager.customCuilianLevelList.get(Integer.parseInt(args[1]) - 1)).quenchingProtectRune == null && pp != null) {
                        pp.sendMessage("[" + NewCustomCuiLian.getPlugin(NewCustomCuiLian.class).getName() + "]不存在的保护符");
                    }

                    item2 = ((Level)NewCustomCuiLian.customCuilianManager.customCuilianLevelList.get(Integer.parseInt(args[1]) - 1)).quenchingProtectRune;
                    item2.setAmount(sl2);
                    if (pp != null) {
                        pp.getInventory().addItem(new ItemStack[]{item2});
                    }
                }
            }
        }

        return true;
    }
}
